#include "FiveWin.ch"

static lRegistered := .f.

//----------------------------------------------------------------------------//

CLASS TMsgBar FROM TWindow

   DATA   cMessage, cMsgDef

   METHOD New( oWnd, cPrompt ) CONSTRUCTOR
   METHOD Adjust()
   METHOD Paint()
   METHOD SetMsg( cText )

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( oWnd, cPrompt ) CLASS TMsgBar

   local oRect := oWnd:GetCliRect()

   DEFAULT cPrompt := ""

   ::nClrPane = COLOR_BTNFACE + 1
   ::oWnd     = oWnd
   ::cMessage := ::cMsgDef  := cPrompt
   ::nStyle   = nOR( WS_VISIBLE, WS_CHILD, WS_OVERLAPPED, WS_BORDER )
   ::nLeft    = -1
   ::nTop     = oRect:nBottom - 25
   ::nBottom  = oRect:nBottom 
   ::nRight   = oRect:nRight  + 1

   if ! lRegistered
      ::Register()
      lRegistered = .t.
   endif

   ::Create()

return

//----------------------------------------------------------------------------//

METHOD Adjust() CLASS TMsgBar

   local rctParent := ::oWnd:GetCliRect()

   ::SetCoors( TRect():New( rctParent:nBottom - 25, rctParent:nLeft - 1,;
                            rctParent:nBottom, rctParent:nRight ) )
return

//----------------------------------------------------------------------------//

METHOD Paint() CLASS TMsgBar

   local aRect := GetClientRect( ::hWnd )

   ::GetDC()

   SetTextColor( ::hDC, CLR_BLACK )
   SetBkColor( ::hDC, CLR_LIGHTGRAY )
   ExtTextOut( ::hDC, 4, 8, { aRect[ 1 ] + 4, aRect[ 2 ] + 4,;
               aRect[ 3 ] - 4, aRect[ 4 ] - 8 }, ::cMessage )
   WndRaised( ::hWnd, ::hDC )
   WndBoxIn( ::hDC,;
          { aRect[ 1 ] + 3, aRect[ 2 ] + 3, aRect[ 3 ] - 4, aRect[ 4 ] - 4 } )

   ::ReleaseDC()

return

//----------------------------------------------------------------------------//

METHOD SetMsg( cText ) CLASS TMsgBar

   local aRect := GetClientRect( ::hWnd )

   ::GetDC()

   ::cMessage = If( Empty( cText ), ::cMsgDef, cText )
   SetTextColor( ::hDC, CLR_BLACK )
   SetBkColor( ::hDC, CLR_LIGHTGRAY )
   ExtTextOut( ::hDC, 4, 8, { aRect[ 1 ] + 4, aRect[ 2 ] + 4,;
               aRect[ 3 ] - 4, aRect[ 4 ] - 8 }, ::cMessage )

   ::ReleaseDC()

return

//----------------------------------------------------------------------------//
